package com.henu.rescue.service.impl;


import com.henu.rescue.entity.Organization;
import com.henu.rescue.mapper.OrgMapper;
import com.henu.rescue.service.OrgService;
import com.henu.rescue.utils.Page;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrgServiceImpl implements OrgService {

    @Autowired
    private OrgMapper orgMapper;

    @Override
    public Page<Organization> selectOrgInfoByPage(Page<Organization> page) {
        List<Organization> orgList = orgMapper.selectOrgInfoByPage(page);
        page.setList(orgList);
        //查询总数
        int totalCount =orgMapper.getCountByPage(page);
        page.setTotalCount(totalCount);
        return page;
    }

    @Override
    public Integer addOrg(Organization organization) {
        return orgMapper.addOrg(organization);
    }

    @Override
    public Integer deleteOrg(Integer orgId) {
        return orgMapper.deleteOrg(orgId);
    }

    @Override
    public Integer updateOrg(Organization organization) {
        return orgMapper.updateOrg(organization);
    }

    @Override
    public List<Organization> getAllOrg() {
        return orgMapper.getAllOrg();
    }

    @Override
    public String getNameById(Integer orgId) {
        return orgMapper.getNameById(orgId);
    }
}
